﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HROReporting.Services.Mapping;
using HROReporting.Services.Interfaces;
using HROReporting.Model.SchoolLocaties;
using HROReporting.Infrastructure.UnitOfWork;
using HROReporting.Services.Messaging.SchoolLocatieService;

namespace HROReporting.Services.Implementations
{
    public class SchoolLocatieService : ISchoolLocatieService
    {
        private readonly ISchoolLocatieRepository _locatieRepository;
        private readonly IUnitOfWork _uow;

        public SchoolLocatieService(ISchoolLocatieRepository locatieRepository, IUnitOfWork uow)
        {
            _locatieRepository = locatieRepository;
            _uow = uow;
        }

        public GetAllLocatiesResponse GetAllSchoolLocaties()
        {
            GetAllLocatiesResponse response = new GetAllLocatiesResponse();

            IEnumerable<SchoolLocatie> schoolLocaties = _locatieRepository.FindAll();

            response.SchoolLocatieViews = schoolLocaties.ConvertToSchoolLocatieIndexView();

            return response;
        }


        public GetSchoolLocatieByResponse GetSchoolLocatieByLocatie(GetSchoolLocatieByRequest request)
        {
            GetSchoolLocatieByResponse response = new GetSchoolLocatieByResponse();

            response.SchoolLocatie = _locatieRepository.GetSchoolLocatieByLocatie(request.SchoolLocatie).ConvertToSchoolLocatieView();

            return response;
        }

        public GetVergaderRuimteByResponse GetVergaderRuimteBy(GetVergaderRuimteByRequest request)
        {
            GetVergaderRuimteByResponse response = new GetVergaderRuimteByResponse();

            response.VergaderRuimte = _locatieRepository.GetSchoolLocatieByLocatie(request.SchoolLocatie).GetVergaderRuimte(request.VergaderRuimteCode).ConvertToVergaderRuimteView();

            return response;
        }
    }
}
